public class Solution125 {
    public boolean isPalindrome(String s) {
        s=s.toLowerCase();
        char[] chars=s.toCharArray();
        for (int l=0,r=s.length()-1;l<r;l++,r--){
            while (l<r && !(chars[l]>='a'&&chars[l]<='z' || chars[l]>='0' && chars[l]<='9')){
                l++;
            }
            while (l<r && !(chars[r]>='a'&&chars[r]<='z'|| chars[r]>='0' && chars[r]<='9')){
                r--;
            }
            if (l<r){
                if (chars[l]!=chars[r]){
                    return false;
                }
            }
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(new Solution125().isPalindrome("A man, a plan, a canal: Panama"));
    }
}
